package com.zjitc.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingletonTemplate {
    private static JdbcTemplate jdbcTemplate=null;
    public static JdbcTemplate getJdbcTemplate(){
        if (jdbcTemplate==null){
            DruidDataSource druidDataSource=new DruidDataSource();
            druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
            druidDataSource.setUrl("jdbc:mysql://localhost:3306/test");
            druidDataSource.setUsername("root");
            druidDataSource.setPassword("root");
            jdbcTemplate=new JdbcTemplate(druidDataSource);
        }
        return jdbcTemplate;
    }
}
